/* Ejercicio 5.15
   ejer5_15.c */
#include <stdio.h>
#include <math.h>

/* prototypes */
double hypotenuse( double side1, double side2  );

/* function main begins program execution */
int main( void )
{
    printf( "%10s%10s%10s%15s\n", "Triangle", "Side1", "Side2", "Hypotenuse" );
    printf( "%10d%10.1f%10.1f%15.2f\n", 1, 3.0, 4.0, hypotenuse( 3.0, 4.0 ) );
    printf( "%10d%10.1f%10.1f%15.2f\n", 2, 5.0, 12.0, hypotenuse( 5.0, 12.0 ) );
    printf( "%10d%10.1f%10.1f%15.2f\n", 3, 8.0, 15.0, hypotenuse( 8.0, 15.0 ) );
    return 0; /* indicate that program ended successfully */
} /* end function main */

/* Calculates the hypotenuse of a triangle, giving the other 2 sides */
double hypotenuse( double side1, double side2  )
{
    return sqrt( side1 * side1 + side2 * side2 );
}
